package models

import com.jfinal.plugin.activerecord.Model

class UserM: Model<UserM>() {
    companion object{
        val AGENT by lazy {
            UserM()
        }
        const val TABLE_NAME = "user"
        const val ID = "id"
        const val USERNAME = "username"
        const val PASSWORD = "password"
        const val PHONE = "phone"
        const val REGISTER_TIME = "registerTime"
        const val STATE = "state"

        fun findUserByPhone(phone: String): List<UserM>{
            return AGENT.find("select * from $TABLE_NAME where $PHONE = ?", phone)
        }

        fun findUserByUsername(username: String): List<UserM> {
            return AGENT.find("select * from $TABLE_NAME where $USERNAME = ?", username)
        }
    }
}